package com.woniuxy.Listener;

import javax.servlet.*;
import javax.servlet.annotation.WebListener;

/**
 * @auther linke
 * @create 2021-10-25 11:19
 * 监听器功能实现
 * Request对象
 */
@WebListener
public class MyServletRequestListener implements ServletRequestListener {


    @Override
    public void requestDestroyed(ServletRequestEvent sre) {
        System.out.println("MyServletRequestListener...requestDestroyed...监听关闭");
    }

    /**
     * 监听对象访问记录
     * @param sre
     */
    @Override
    public void requestInitialized(ServletRequestEvent sre) {
        System.out.println("MyServletRequestListener...requestInitialized...监听启动");

        //获取访问对象信息
        ServletRequest servletRequest = sre.getServletRequest();
        System.out.println(servletRequest.getRemoteAddr());

    }
}
